<template>
	<el-form ref="form" :model="form" label-width="80px">
	  <el-form-item label="登录名">
	    <el-input v-model="form.username"></el-input>
	  </el-form-item>
	  <el-form-item label="密码">
	    <el-input v-model="form.password"></el-input>
	  </el-form-item>
	
	 
	  <el-form-item>
	    <el-button type="primary" @click="login">登录</el-button>
	    <el-button>取消</el-button>
	  </el-form-item>
	</el-form>
</template>

<script>
	
	import axios from "axios"
	 export default {
	    data() {
	      return {
	        form: {
	          username: '',
			  password:''
	        }
	      }
	    },
	    methods: {
	      login() {
	        console.log('submit!');
			//发起axios请求, 去后台查询 ,是否登录成功
			/**
			 * post请求目前用到了2哥参数:
			 * 第一个参数:请求路径
			 * 第二参数:传过去的数据
			 */
			
			axios.post('http://localhost:8100/api-user/v1/admin/user/login',this.form).then(res=>{
				//console.log(res)
				console.log(res.data)
				if(res.data.code==1){
					//直接跳转
					 this.$router.push('/index');
				}else{
					 this.$message(res.data.message);
				}
			})
			
	      }
	    }
	  }
</script>

<style>
</style>